import { ref } from "vue";
import { defineStore } from "pinia";
import type { IChatItem } from "@api/chat";

export const useChatstore = defineStore(
  "chatStore",
  () => {
    // 列表数据
    const menuList = ref<{ name: string; list: IChatItem[] }[]>([
      { name: "今日", list: [] },
      { name: "最近", list: [] },
    ]);
    // 菜单列表id
    const menuId = ref(1);
    // 当前页
    const page = ref(1);

    const init = (id: number) => {
      page.value = 1;
      menuId.value = id;
      menuList.value = [
        { name: "今日", list: [] },
        { name: "最近", list: [] },
      ];
    };

    return {
      menuList,
      menuId,
      page,
      init,
    };
  },
  { persist: true }
);
